<?php

namespace App\Providers;

use FFMpeg\FFMpeg;
use FFMpeg\FFProbe;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerSingleObject();
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    private function registerSingleObject()
    {
//            $ffmpeg = FFMpeg::create(array(
//           'ffmpeg.binaries'  => '/usr/local/ffmpeg/ffmpeg',
//           'ffprobe.binaries' => '/usr/local/ffmpeg/ffprobe',
//           'timeout'          => 3600, // The timeout for the underlying process
//           'ffmpeg.threads'   => 12,   // The number of threads that FFMpeg should use
//       ));

        $this->app->singleton('ffmpeg', function ($app) {
            return FFMpeg::create([
                'ffmpeg.binaries'  => config('app.ffmpeg_uri'),
                'ffprobe.binaries' => config('app.ffprobe_uri'),
            ]);
        });
        $this->app->singleton('ffprobe', function ($app) {
            return FFProbe::create([
                'ffprobe.binaries' => config('app.ffprobe_uri'),
            ]);
           /* return FFProbe::create([
                'ffprobe.binaries' => '/usr/local/ffmpeg/ffprobe',
            ]);*/
        });
    }

}
